package com.tyk.bookstore.front.product.controller;


import com.tyk.bookstore.front.common.core.model.result.R;
import com.tyk.bookstore.front.product.service.BookService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.media.Schema;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.validation.constraints.Min;
import jakarta.validation.constraints.NotNull;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author tyk
 * @description 书籍点赞
 */
@Tag(name = "书籍管理/点赞管理", description = "点赞管理")
@RequiredArgsConstructor
@RestController
@RequestMapping("api/product/praise")
public class BookPraiseController {

    private final BookService bookService;

    @PostMapping({"{bookId}"})
    @Operation(summary = "点赞/取消点赞书籍", description = "点赞/取消点赞书籍")
    public R<Object> praiseOrCancel(
            @Schema(description = "书籍ID")
            @NotNull @Min(1)
            @PathVariable Long bookId
    ) {
        bookService.praiseOrCancel(bookId);
        return R.ok();
    }
}

